package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.OwnerSignature;
import com.softer.wxzj.entity.ReqList;
import com.softer.wxzj.service.OwnerSignatureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * OwnerSignatureController class
 *
 * @author ljm
 * @date 2019/7/16
 */
@RestController
@RequestMapping("/ownerSignature")
@Slf4j
public class OwnerSignatureController {

    @Autowired
    OwnerSignatureService ownerSignatureService;
    /**
     * 获取业主签字明细
     *
     * @param ownerSignature  业主实例
     * @return 业主分摊明细
     */
    @RequestMapping("/getInfo")
    public PageInfo<OwnerSignature> selectByOwnerSignatureInfo(Page page, OwnerSignature ownerSignature) {
        return ownerSignatureService.selectByOwnerSignatureInfo(page,ownerSignature);
    }
    /**
     * 业主签字更改签名状态
     * @param  reqList
     *      no 0：同意 1：不同意 2:未表决 3：放弃
     *      list<String> 更改状态的id
     * @return 结果
     */
    @RequestMapping("/update")
    public CommonResult update(@RequestBody ReqList reqList) {
        return ownerSignatureService.updateByPrimaryKeySelective(reqList.getList(),reqList.getNo());
    }
    /**
     * 业主信息汇总
     * @param reqId 项目id
     * @return 汇总信息
     */
    @RequestMapping("/getSum")
    public OwnerSignature getSum(String reqId) {
        return ownerSignatureService.getSum(reqId);
    }
}
